package com.guw.AWT;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

//Panel是一个空间，需要放在Frame里面
public class TestPanel {
    public static void main(String[] args) {
        Frame frame = new Frame();
        //布局
        Panel panel = new Panel();

        //设置布局
        frame.setLayout(null);
        //坐标
        frame.setBounds(300,300,500,500);
        //背景颜色
        frame.setBackground(new Color(40,161,35));
        //Panel设置坐标，相对于frame
        panel.setBounds(50,50,400,400);
        //颜色
        panel.setBackground(new Color(193,15,60));

        //添加面板
        frame.add(panel);

        //设置可见性
        frame.setVisible(true);
        //设置是否可改变大小
        frame.setResizable(false);

        //设置监听,监听窗口关闭窗口
        //适配器模式
        frame.addWindowListener(new WindowAdapter() {
            //窗口点击关闭的时候需要做的事情
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        /*frame.addWindowListener(new WindowListener() {
            @Override
            public void windowOpened(WindowEvent e) {

            }

            @Override
            public void windowClosing(WindowEvent e) {

            }

            @Override
            public void windowClosed(WindowEvent e) {

            }

            @Override
            public void windowIconified(WindowEvent e) {

            }

            @Override
            public void windowDeiconified(WindowEvent e) {

            }

            @Override
            public void windowActivated(WindowEvent e) {

            }

            @Override
            public void windowDeactivated(WindowEvent e) {

            }
        });*/



    }
}
